using System;
using System.Data.Common;

namespace SqlHelper
{
    public class DbFactory
    {
        private DbProviderFactory provider;

        public DbFactory()
            : this("System.Data.SqlClient")
        {
        }

        public DbFactory(string providerInvariantName)
        {
            ProviderName = providerInvariantName;
            provider = DbProviderFactories.GetFactory(providerInvariantName);
        }

        public virtual string ProviderName { get; private set; }

        public virtual DbCommand CreateCommand()
        {
            return this.provider.CreateCommand();
        }
        public virtual DbCommandBuilder CreateCommandBuilder()
        {
            return this.provider.CreateCommandBuilder();
        }
        public virtual DbConnection CreateConnection()
        {
            return this.provider.CreateConnection();
        }
        public virtual DbConnectionStringBuilder CreateConnectionStringBuilder()
        {
            return this.provider.CreateConnectionStringBuilder();
        }
        public virtual DbDataAdapter CreateDataAdapter()
        {
            return this.provider.CreateDataAdapter();
        }
        public virtual DbDataSourceEnumerator CreateDataSourceEnumerator()
        {
            return this.provider.CreateDataSourceEnumerator();
        }
        public virtual DbParameter CreateParameter()
        {
            return this.provider.CreateParameter();
        }
    }
}
